package com.wlf.util;

import org.springframework.stereotype.Component;

/**
 * @author lingfeng.wei
 * @date 2021/7/6 14:05
 */
@Component
public class MqUtils {

    /**
     * 计算存储队列index
     * @param
     * @return
     */
    public static int calcQueueIndex(Integer maxSize,String id) {
        id=id.substring(0,id.length()/2);
        int index =Integer.parseInt(id)%10;
        if (index > maxSize) {
            index = (int)(Math.random() * maxSize);
        }
        return index;
    }
}
